<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="checkbox" onclick="allS()" value="全选"/><a id="sel">全选</a>
    <br/><br/>
    <input type="checkbox" class="game" value="武器"/>武器<br/>
    <input type="checkbox" class="game" value="防具"/>防具<br/>
    <input type="checkbox" class="game" value="坐骑"/>坐骑<br/>
    <input type="checkbox" class="game" value="服饰"/>服饰<br/>
    <script>
        //获取所有类名为game的复选框
        var a = document.getElementsByClassName("game");
        var b = document.getElementById('sel')
        function allS(){
            if(b.innerHTML=="全选"){
                for(var i=0;i<a.length;i++){
                    a[i].checked =true;
                }
                b.innerHTML="全不选"
            }else{
                for(var i=0;i<a.length;i++){
                    a[i].checked =false;
                }
                b.innerHTML="全选"
            }
        }
    </script>
</body>
</html>